<template>
  <div class="content">
    <!-- <div style="padding:12px;background-color: #0d8bc5;" @click="netReadStudent">测试获取用户信息</div> -->
    <div style="
			border-bottom: 1px solid #99999980;
			height: 44px;background-color: #FFFFFF;
            display: flex;flex-direction: row;
            align-items: center;justify-content: center;">
      <div
        @click='tabClick(0)'
        :style="{'padding': '5px 12px','background-color'
        :tabindex == 0?'#007AFF':'#f5f5f5',
        'font-size': '14px','color':tabindex==0?'#ffffff':'#222222'}"
      >个人资料</div>
      <div
        @click='tabClick(1)'
        :style="{'padding': '5px 12px','background-color'
        :tabindex == 1?'#007AFF':'#f5f5f5','font-size': '14px','color':tabindex==1?'#ffffff':'#222222'
			}"
      >工作台</div>
    </div>

    <div style="flex: 1;overflow-y: auto;">
      <workbench v-if="tabindex == 1" />
      <personindex v-else />
      <!-- <div v-else style="flex: 1;">
                <hasbindstudent v-if="hasBind" />
                <personinfo v-else />
            </div> -->
    </div>
  </div>
</template>

<script>
import workbench from "@/views/workbench/workbench";
import personindex from "@/views/personinfo/personinfo-index.vue";
import personinfo from "@/views/personinfo/personinfo-unbind";
import { readStudentWX } from "../../api/person";
import { mapMutations } from "vuex";

export default {
  components: {
    workbench,
    personindex,
  },
  data() {
    return {
      tabindex: 1,
      hasBind: false,
      info: "",
      wxuid: undefined, //微信信息
    };
  },
  onLoad() {},
  created() {},
  mounted() {

    // szwtest
    // sessionStorage.setItem("wxUserId", "kkksu");
    // global.wxuid = "kkksu"
    // this.wxuid = global.wxuid;
    // // end



    // this.getwxuid();
  },
  computed: {},
  methods: {
      ...mapMutations(['page500']),
    tabClick(idx) {
      this.tabindex = idx;
    },
    pageUpdate(e) {
      this.hasBind = e.data;
    },
    getwxuid() {
      let self = this;
      wx.invoke("getCurExternalContact", {}, function (res) {
        if (res.err_msg == "getCurExternalContact:ok") {
          self.wxuid = res.userId; //返回当前外部联系人userId
          self.$toast(self.wxuid);
          sessionStorage.setItem("wxUserId", self.wxuid);
          self.netReadStudent();
        } else {
          //错误处理
          console.error("*******************");
          console.error(res);
          console.error("*******************");
        }
      });
    },
    netReadStudent() {
      let fi = { wxUserId: this.wxuid };
      let self = this;
      readStudentWX(fi)
        .then((res) => {
          if (res.data.id == undefined) {
            self.hasBind = false;
          } else {
            self.hasBind = true;
          }
        })
        .catch((e) => {
          console.error("*******************");
          console.error(e);
          console.error("*******************");
        });
    },
  },
};
</script>

<style>
.content {
  background-color: #ffffff;
  width: 100%;
  display: flex;
  flex-direction: column;
}
</style>